/*
 * Copyright (c)  2017
 * All rights reserved.
 * ProductInfo.java 2017-09-13 下午7:47
 */

package com.ueboot.weishop.entity.setting;

import com.ueboot.weishop.entity.IDEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;


/**
 * 描述:基础区域表，保存全国各市区信息
 * 级联查询使用
 *
 * @author yangkui create on 2017-09-13 下午7:47.
 * @since 1.0
 */
@Data
@NoArgsConstructor
@Entity(name = "WS_AREA")
public class AreaEntity extends IDEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "WS_AREA")
    @GenericGenerator(name = "WS_AREA", strategy = "enhanced-table", parameters = {
            @org.hibernate.annotations.Parameter(name = "table_name", value = "WS_TABLE_SEQUENCE"),
            @org.hibernate.annotations.Parameter(name = "segment_value", value = "WS_AREA"),
            @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled") })
    @Column(name = "ID",columnDefinition = "INT(20) COMMENT 'id主键'",length = 20)
    private Long id;

    /**
     * 地区名称
     */
    @Column(name = "NAME",columnDefinition = "VARCHAR(200) COMMENT '地区名称'",length = 200)
    private String name;

    /**
     * 地区代码
     */
    @Column(name = "CODE",columnDefinition = "VARCHAR(200) COMMENT '地区代码'",length = 200)
    private String code;

    /**
     * 父级ID集合，使用/分割
     */
    @Column(name = "FULL_PATH_NAME",columnDefinition = "VARCHAR(2000) COMMENT '父级的全路径名称，使用/分割'",length = 2000)
    private String fullPathName;

    /**
     * 父级的全路径ID，使用/分割
     */
    @Column(name = "FULL_PATH_ID",columnDefinition = "VARCHAR(200) COMMENT '父级的全路径ID，使用/分割'",length = 200)
    private String fullPathId;

    /**
     * 排序，值越大，越靠前
     */
    @Column(name = "RANK",columnDefinition = "INT(11) COMMENT '排序，值越大，越靠前'",length = 11)
    private int rank;

    /**
     * 层级
     */
    @Column(name = "LEVELS",columnDefinition = "INT(11) COMMENT '层级'",length = 11)
    private int level;


    /**
     * 父级，如果为空就是根级别的类目
     */
    @ManyToOne
    @JoinColumn(name="PARENT_ID",columnDefinition = "INT(20) COMMENT '父级，如果为空就是根级别的类目'")
    private AreaEntity parent;
}